#ifndef __MEMORYSTREAM_H__

#define __MEMORYSTREAM_H__

#include <Arduino.h>
#include <stdio.h>


class MemoryStream{

private:
	uint16 mSize=0;
	uint16 mLength=0;
	uint16 mGetIndex=0;
	uint16 mPutIndex=0;
	void get_index_next(uint16 length);
	void put_index_next(uint16 length);
public:
	uint8* mMemBuffer=NULL;
	MemoryStream(uint16 size);
	~MemoryStream();
	void Flush();
	uint16 GetSize();
	uint16 GetDataLength();
	int16 Peek();
	uint16 PeekBytes(uint8* buffer,uint16 bufferSize,uint16 peekLength);
	int16 Read();
	uint16 ReadBytes(uint8* buffer,uint16 bufferSize,uint16 readLength);
	uint16 Write(uint8 byte);
	uint16 WriteBytes(uint8* buffer,uint16 writeLength);
};

#endif 